{{extend ("./parent.html")}} 
{{block "content"}}
<div class="panel panel-default">
    <div class="panel-heading">
        <ol class="breadcrumb">
            <li>
                <a href="#">首页</a>
            </li>
            <li>
                <a href="#">学生管理</a>
            </li>
            <li class="active">学生列表</li>
        </ol>
    </div>
    <div class="panel-heading">
        <div class="input-group">
            <span class="input-group-addon" id="basic-addon1">学生姓名</span>
            <input type="text" class="form-control" id="studentNameId" placeholder="请输入学生姓名进行查询" aria-describedby="basic-addon1" style="width:200px;margin-right:10px;"
                value="{{keywords}}">
            <input type="button" class="btn btn-success" onclick='search()' value="查找" style="margin-right:10px;">
            <input type="button" class="btn btn-success" value="新增" onclick="window.location='/studentmanager/add'">
        </div>
    </div>
    <div class="panel-body">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th>姓名</th>
                    <th>年龄</th>
                    <th>性别</th>
                    <th>手机号码</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {{each students}}
                    <tr>
                        <td>{{$value.name}}</td>
                        <td>{{$value.age}}</td>
                        <td>{{$value.sex}}</td>
                        <td>{{$value.phone}}</td>
                        <td>
                            <a href="/studentmanager/edit/{{$value._id+''}}" class="btn btn-success">编辑</a> |
                            <input onclick="deleteStudent({{$value._id}})" type="button" class="btn btn-danger" value="删除">
                        </td>
                    </tr>
                {{/each}}
            </tbody>
        </table>
    </div>
</div>
<script>
    function search() {
        location.href=`/studentManager/list?keywords=${$('#studentNameId').val()}`
    }

    function deleteStudent(_id) {
        if (confirm('确定删除吗!!')) {
            location.href =`/studentManager/delete/${_id}`
        }else{

        }
    }
</script>

{{/block}}